<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Hobby_model extends CI_Model
{
	
	public function __construct()
	{
		parent::__construct();

	}
	function users_getall($userid)
	{
	   
		/*$users = $this->db->get('users',$userid);
	    return $users->result();*/
	}

	function hobbies_getall()
	{
	    $query2 = $this->db->get('hobbies');
	    return $query2->result();
	}
	/*function skills_insert($insert)
	{
		//print_r($insert);
		//exit;
	   $this->db->insert('skills',$insert);
	 	 //  return $this->db->insert($add);	
	}*/
	
	function hobbies_insert($hobbyname,$file_name)
	{
 	$this->db->insert('hobbies',array('name'=>$hobbyname,'location'=>$file_name));	
	}

	
	function user_hobbies_insert($insert)
	{
		
				foreach($insert as $hobbies)			
				{
				$this->db->insert('user_hobbies',$hobbies);
				}
				
	}
	
	

	function hobbies_getall_by_id($id)
	{
		$this->db->select('user_hobbies.*');
    	$this->db->from('users');
    	$this->db->join('user_hobbies', 'user_id = users.id');
		$this->db->where('user_hobbies.user_id =',$id);
		
	   
		$hobbies = $this->db->get();
	    return $hobbies->result();
	}
	
		
	
	function hobbyimage($id)
	{
		$this->db->select('user_hobbies.*,hobbies.*');
    	$this->db->from('hobbies');
    	$this->db->join('user_hobbies', 'hobbies_id = hobbies.id');
		$this->db->where('user_hobbies.user_id =',$id);
		$hobbyimage = $this->db->get();
		return $hobbyimage->result();
	}
	





}
